<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gerenciamento Escola - Usuário</title>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/validacao.js"/></script>

<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="divLogout"><a href="logoutServlet"><c:out value="Logout(${sessionUser.login})"></c:out></a></div>

<div class="tablegrid">

		<table class="tableListUser" >
			<tr height="28px">
				<td class="celListCenter"> <a href="listarProfessores">Professores</a></td>
				<td class="celListCenter"> <a href="listarAlunos">Alunos</a></td>
				<td class="celListCenter"> <a href="listarDisciplinas">Disciplinas</a></td>
				<td class="celListCenter"> <a href="listarUsuarios">Usuários</a></td>
			</tr>
			<tr height="28px">
				<td colspan="4" align="center">Gerenciamento de Usuários</td>
			</tr>
			<tr>
            	<td align="center"  colspan="2">
                    <a href="listarUsuarios"><img class="icone" src="img/icon/user_search.png"/></a>
                </td>
                <td align="center"  colspan="2" >
                    <a><img class="icone" src="img/icon/user_add.png"/></a>
                </td>
            </tr>
            <tr>
            	<td align="center"  colspan="2">
                    <a href="listarUsuarios">Listar Usuarios</a>
                </td>
                <td align="center"  colspan="2" >
                    <a >Adicionar Usuario</a>
                </td>
            </tr>
		</table>			
		<div class="formHeader">Usuário</div>
		
		<div class="erroMsg">
			<c:if test="${not empty param.msg}">
					<c:choose>
						<c:when test="${param.msg eq 'password_empty'}">
							Senha é informação obrigatória.				
						</c:when>
						<c:when test="${param.msg eq 'password_min'}">
							A senha deve conter pelo menos 5 caracteres.				
						</c:when>
						<c:when test="${param.msg eq 'user_name_empty'}">
							Usuário é informação obrigatória.				
						</c:when>
						<c:when test="${param.msg eq 'user_name_invalid_length'}">
							Usuário deve conter de 5 até 30 caracteres.				
						</c:when>
						<c:when test="${param.msg eq 'user_name_exist'}">
							Este nome de usuário já esta em uso.
						</c:when>
						<c:when test="${param.msg eq 'email_empty_or_invalid'}">
							Email inválido.				
						</c:when>
					</c:choose>
			</c:if>
		</div>
		
	<form onsubmit="return verificaUsuario();" action="usuario" method="post">
		<input type="hidden" name="acao" value="salvar" />
		<input type="hidden" name="id" value="${user.id}" />
		<table class="tableform">
						
			<tr>
				<td class="nomeCampo">Login:</td>
				<td><input type="text" id="login" name="login" maxlength="30" size="30" value="${user.login}"/></td>
			</tr>
			<tr>
				<td class="nomeCampo">Senha:</td>
				<td><input type="password" id="senha" name="senha" maxlength="20" size="20" value="${user.senha}" /></td>
			</tr>
			<tr>
				<td class="nomeCampo">Nome:</td>
				<td><input type="text" id="nome" name="nome" maxlength="80" size="40" value="${user.nome}"/></td>
			</tr>
			<tr>
				<td class="nomeCampo">Email:</td>
				<td><input type="text" id="email" name="email" maxlength="60" size="40" value="${user.email}"/></td>
			</tr>
			<tr>
				<td colspan="2" class="celListCenter"><input type="submit" value="Salvar" value="${user}"/></td>
			</tr>
		</table>
	</form>
	
	</div>
	
</body>
</html>
